package com.gm.corejava.book2;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-12-26
 * Time: 上午10:46
 * To change this template use File | Settings | File Templates.
 */
public class ColorTableRenderer extends JPanel implements TableCellRenderer {
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        setBackground((Color)value);

        if(hasFocus){
            setBorder(UIManager.getBorder("Table.cellFocusHighLightBorder"));
        }
        else
            setBorder(null);

        return this;
    }
}
